package jianzhi

func isSymmetric(root *TreeNode) bool {
	if root == nil {
		return true
	}

	return helper28(root, root)

}

func helper28(A, B *TreeNode) bool {

	if (A == nil && B != nil) || (B == nil && A != nil) {
		return false
	}
	if B == nil && A == nil {
		return true
	}

	if A.Val == B.Val {
		return helper28(A.Left, B.Right) && helper28(A.Right, B.Left)
	}

	return false
}
